using System;
using System.Collections.Generic;
using System.Text;

namespace MCromwell.StaffIntranet.Core
{
    public class DomainObjectValidationResult
    {
        private IList<ValidationResultItem> resultItems;

        public DomainObjectValidationResult()
        {
            resultItems = new List<ValidationResultItem>();
        }

        public void Register(ValidationResultItem resultItem)
        {
            resultItems.Add(resultItem);
        }

        public void Merge(IList<ValidationResultItem> resultItems)
        {
            ((List<ValidationResultItem>)this.resultItems).AddRange(resultItems);
        }

        public bool IsValid
        {
            get { return resultItems.Count == 0; }
        }

        public IList<ValidationResultItem> Results
        {
            get { return ((List<ValidationResultItem>)resultItems).AsReadOnly(); }
        }

        public static DomainObjectValidationResult Empty
        {
            get { return new DomainObjectValidationResult(); }
        }

    }
}
